package cn.com.css.taxInspection.gt3.service.impl;

import cn.com.css.taxInspection.gt3.entity.JcDsrwTaskEntity;
import cn.com.css.taxInspection.gt3.mapper.JcDsrwTaskMapper;
import cn.com.css.taxInspection.gt3.service.JcDsrwTaskService;
import cn.com.css.taxInspection.util.TsBqUtils;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class JcDsrwTaskServiceImpl extends ServiceImpl<JcDsrwTaskMapper, JcDsrwTaskEntity> implements JcDsrwTaskService {

    @Override
    public IPage<JcDsrwTaskEntity> queryDsrwList(JcDsrwTaskEntity jcDsrwTaskEntity) {
        IPage<JcDsrwTaskEntity> page = new Page<>(jcDsrwTaskEntity.getPage(), jcDsrwTaskEntity.getLimit());
        LambdaQueryWrapper<JcDsrwTaskEntity> queryWrapper = Wrappers.lambdaQuery();
        // 定时任务ID
        if (TsBqUtils.isNotNull(jcDsrwTaskEntity.getId())) {
            queryWrapper.like(JcDsrwTaskEntity::getId, jcDsrwTaskEntity.getId());
        }
        // 定时任务名称
        if (TsBqUtils.isNotNull(jcDsrwTaskEntity.getBeanName())) {
            queryWrapper.like(JcDsrwTaskEntity::getBeanName, jcDsrwTaskEntity.getBeanName());
        }
        queryWrapper.orderByAsc(JcDsrwTaskEntity::getId);
        return page(page, queryWrapper);
    }
}